<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width,user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="keywords" content="BPMN"/>
    <meta name="description" content="BPMN"/>
    <meta name="author" content="小柒2012" />
    <meta name="site" content="https://blog.52itstyle.vip" />
    <title>BPMN</title>
    <link rel="stylesheet" th:href="@{/iview/styles/iview.css}">
    <script th:src="@{/libs/jquery-3.2.1.min.js}" type="text/javascript"></script>
	<script th:src="@{/libs/vue.min.js}" type="text/javascript"></script>
	<script th:src="@{/layer/layer.js}" type="text/javascript"></script>
	<script th:src="@{/iview/iview.min.js}" type="text/javascript"></script>
	<script th:src="@{/common.js}" type="text/javascript"></script>
</head>
<body>
<div   id="app"  v-cloak >
<div style="padding: 15px;">
      <template>
			<i-form ref="userForm"  :model="formUser"  :rules="ruleValidate"  :label-width="80">
				        <form-item label="用户名" prop="username">
				           <i-input  v-model="formUser.username"  placeholder="请输入用户名"></i-input>
				        </form-item>
				        <form-item label="姓名" prop="nickname">
				           <i-input  v-model="formUser.nickname"  placeholder="请输入姓名"></i-input>
				        </form-item>
				        <form-item label="邮箱" prop="email">
				           <i-input  v-model="formUser.email"  placeholder="请输入邮箱"></i-input>
				        </form-item>
				        <form-item label="角色："  style="margin-bottom:10px" >
				    		    <radio-group  v-model="formUser.roleCode" >
							         <radio v-for="item in role" :label="item.code" :key="item.code">{{item.name}}</radio>
							    </radio-group>
				       </form-item>
			 </i-form>
	  </template>
</div>
</div>
<script>
		var vm = new Vue({
			el: '#app',
			data:{
			    role:[{"code":"user","name":"普通用户"},{"code":"admin","name":"管理员"}],
				formUser : {
				     id:null
				},
				ruleValidate : {
	            	username: [
	                    { required: true, message: '用户名不能为空', trigger: 'blur' }
	                ],
	                password : [
	                    { required: true, message: '密码不能为空', trigger: 'blur' }
	                ],
	                nickname : [
	                     { required: true, message: '姓名不能为空', trigger: 'blur' }
	                ],
	                email : [
	                     { required: true, message: '邮箱不能为空', trigger: 'blur' }
	                ],
	            }
			},
			methods: {
				acceptClick : function(){
					vm.$refs.userForm.validate(function(valid){
		                if (valid) {
		                	$.SaveForm({
								url :  "/user/edit",
								param : vm.formUser,
								json:true,
								success : function(result) {
									pop.info("修改成功");
									$.currentIframe().vm.load();
								}
							});
		                }
		              });
				},
				setForm : function(){
				      $.SetForm({
							url :  "/user/get",
							param : {"id":vm.formUser.id},
							json:true,
							success : function(result) {
								vm.formUser = result;
							}
						});
				}
			},
			created: function(){
				
			}
		});						
</script>
</body>
</html>